package com.company.recruit.spider.task;

import cn.hutool.core.thread.ThreadUtil;
import com.company.recruit.spider.service.SpiderService;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author XiAoXu
 * @date 2021/12/8 13:32
 * @description 爬虫定时任务
 */
@Component("spiderTask")
@EnableScheduling
public class SpiderTask {
    private SpiderService service;

    /**
     * 每天零点更新一次数据(之前的数据做掉)
     */
    @Scheduled(cron = "0 0 0 */1 * ?")
    public void refreshData() {
        ThreadUtil.execAsync(() -> {
            service.pullData();
            service.dealWithData();
        });
    }

}
